<?php
/**
 * Created by Command.
 * User: Vito
 */

declare (strict_types = 1);

namespace app\model;

class Repair extends BaseModel
{

    const STATUS_STAY = 0;
    const STATUS_BEING  = 1;
    const STATUS_COMPLETE  = 2;
    const STATUS_RATE  = 3;

    protected $statusEnum = [
        self::STATUS_STAY => '待处理',
        self::STATUS_BEING  => '处理中',
        self::STATUS_COMPLETE => '已处理',
        self::STATUS_RATE => '已评价'
    ];

    /**
     * @Description: 关联用户表
     * @author: xiayu <cb1071403016@126.com>
     * @Date: 2022-11-05 09:22:07
     * @version: 1.0.0
     * @return [type]
     */    
    public function user(){

        return $this->belongsTo('User','user_id');
    }
    /**
     * @Description: 关联维护员
     * @author: xiayu <cb1071403016@126.com>
     * @Date: 2022-11-05 09:22:07
     * @version: 1.0.0
     * @return [type]
     */
    public function RpUser()
    {

        return $this->belongsTo('repairUser', 'user_id');
    }
    /**
     * @Description: 关联维修员
     * @author: xiayu <cb1071403016@126.com>
     * @Date: 2022-11-05 09:56:13
     * @version: 1.0.0
     * @return [type]
     */    
    public function repairUser(){
        return $this->belongsTo('RepairUser','repair_user_id')->bind([
            'repair_name'=>'real_name'
        ]);
    }
    /**
     * @Description: 修改报修记录
     * @author: xiayu <cb1071403016@126.com>
     * @Date: 2022-11-05 09:57:09
     * @version: 1.0.0
     * @return [type]
     */
    public static function saveRepairRecord($where,$data){

        return self::where($where)->update($data);
    }
}
